import { Component, ViewChild } from '@angular/core';
import { NavController, Slides, IonicPage } from 'ionic-angular';
import { HttpServiceProvider } from '../../providers/http-service/http-service';

@IonicPage()
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
	  @ViewChild(Slides) slides: Slides;
	  
    homeOptions = {
        initialSlide: 0,
        loop: true,
        autoplay:2000,
        autoplayDisableOnInteraction: false
    };

    params: any = {data:[], events:{}};

  	constructor(public navCtrl: NavController,
                public http: HttpServiceProvider) {
      this.homelist()

      this.params.events = {
        'onDetail': (item: any) => {
            this.navCtrl.push('ActdetailPage', {item: item});
        }
      }
  	}

    homelist(){
        this.http.homeActlist((result) =>{
            this.params.data[0] = [result.list[0],result.list[1]]
            this.params.data[1] = [result.list[2],result.list[3]]
            console.log(this.params.data)
        })
    }

  	goToSlide() {
    	this.slides.slideTo(2, 500);
  	}

  	ngAfterViewInit() {
	    this.slides.freeMode = true;
	  }

}
